package com.atguigu.observer;

/**
 * 类是核心
 * 1.包含最新的天气情况信息
 * 2.包含CurrentConditions 对象
 * 3.当数据有更新时，就主动的调用 CurrentConditions 对象 update 方法（含display），这样他们（接入方）就看到最新的信息
 * @author guijie
 *
 */
public class WeatherData {
	private float temperature;//温度
	private float pressure;//气压
	private float humidity;//湿度
	private CurrentConditions currentConditions;

	public WeatherData(CurrentConditions currentConditions) {
		this.currentConditions = currentConditions;
	}

	public float getTemperature() {
		return temperature;
	}

	public float getPressure() {
		return pressure;
	}

	public float getHumidity() {
		return humidity;
	}

	public void dataChange() {
		//调用接入方 update
		currentConditions.update(temperature, pressure, humidity);
	}
	
	//当数据有更新时，就调用 setData 
	public void setData(float temperature, float pressure, float humidity) {
		this.temperature = temperature;
		this.pressure = pressure;
		this.humidity = humidity;
		//调用 dataChange ，将最新的信息 推送给 接入方 currentConditions
		dataChange();
	}
	
}
